import java.util.Scanner;

public class NGuessNumber {
    static int a;
    static int b;
    static int c;
    static int d;

    public static void main(String[] args) {


        Guessnumber();

    }

    public static void Guessnumber() {
        System.out.println("系统正在生成数字，请稍后。。。");
//       生成4位数字
        int A = 0, B = 0;
        a = (int) (Math.random() * 10);
        b = (int) (Math.random() * 10);
        c = (int) (Math.random() * 10);
        d = (int) (Math.random() * 10);
//       判断是否重复方法
        cs();
        System.out.println("系统已随机生成4个数字!");
        System.out.println("请输入4个数字:");
        System.out.println(a * 1000 + b * 100 + c * 10 + d);
        for (int i = 0; i < 11; i++) {

            if (i == 10) {
                System.out.println("游戏次数达到10次，挑战失败！");
                break;
            } else if (i == 7) {
                System.out.println("剩余3次机会，请把握好机会！");
            }


            if (A != 4) {
                A = 0;
                B = 0;
                Scanner sc = new Scanner(System.in);
                int q = sc.nextInt();
//             System.out.println(q);
                int q1 = q / 1000;
                int q2 = (q - q1 * 1000) / 100;
                int q3 = (q - q1 * 1000 - q2 * 100) / 10;
                int q4 = (q - q1 * 1000 - q2 * 100) % 10;
                if (a == q1) {
                    A++;
                } else if (a == q2 || a == q3 || a == q4) {
                    B++;
                }
                if (b == q2) {
                    A++;
                } else if (b == q2 || b == q3 || b == q4) {
                    B++;
                }
                if (c == q3) {
                    A++;
                } else if (c == q2 || c == q3 || c == q4) {
                    B++;
                }
                if (d == q4) {
                    A++;
                } else if (d == q2 || d == q3 || d == q4) {
                    B++;
                }

                System.out.println(A + "A" + B + "B");
            } else {
                System.err.println("恭喜挑战成功！");
                break;

            }
        }
    }

    private static void cs() {
        if (a == b || a == c || a == d || b == c || b == d || c == d) {
            a = (int) (Math.random() * 10);

        }
    }
}

